/**
 * This file is Copyright © 2008 Software Craftsmen Limited. All Rights Reserved.
 */
package com.softwarecraftsmen.functors;

import org.jetbrains.annotations.NotNull;

public abstract class UnaryFunctor<A>
{
	public abstract void closure(final @NotNull A a);

	@NotNull
	public final UnaryFunctor<A> curry()
	{
		return this;
	}

	@NotNull
	public final NullaryFunctor curry(final @NotNull A a)
	{
		return new NullaryFunctor()
		{
			public void closure()
			{
				UnaryFunctor.this.closure(a);
			}
		};
	}

	@NotNull
	public UnaryReturningFunctor<A, Nothing> toReturningFunctor()
	{
		return new UnaryReturningFunctor<A, Nothing>()
		{
			@NotNull
			public Nothing closure(final @NotNull A a)
			{
				UnaryFunctor.this.closure(a);
				return Nothing.Nothing;
			}
		};
	}

	@NotNull
	public static <A> UnaryFunctor<A> identityUnaryFunctor()
	{
		return new UnaryFunctor<A>()
		{
			public void closure(final @NotNull A a)
			{
			}
		};
	}
}
